/* 封装文章接口 */

import axios from '@/utils/request'

/**
 * 获取文章列表数据
 * @param {*} channelId 频道id
 * @param {*} timestamp 时间戳
 * @returns
 */
export function getArticleList(channelId, timestamp) {
  return axios({
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}

/**
 * 对文章不喜欢
 * @param {*} target 不喜欢的文章id
 * @returns
 */

export function articleDisLike(target) {
  return axios({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target
    }
  })
}

/**
 * 举报文章
 * @param {*} articleId 文章类型
 * @param {*} type 举报类型编号
 */
export const articleReport = (artId, type) => {
  return axios({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: artId,
      type
    }
  })
}

/**
 * 获取新闻详情
 *
 * @export
 * @param {*} artId 文章Id
 * @return {*}
 */
export function getArtilceDetail(artId) {
  return axios({ url: '/v1_0/articles/' + artId })
}

/**
 * 关注作者
 *
 * @export
 * @param {*} target 关注的用户的id
 * @return {*}
 */
export function followUser(target) {
  return axios({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}

/**
 * 取消关注作者
 *
 * @export
 * @param {*} target 关注的用户的id
 * @return {*}
 */
export function unFollowUser(target) {
  return axios({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + target
  })
}
